package com.yn.front.driver;

import com.yn.common.response.driver.BasicInfoResponse;
import com.yn.common.response.driver.DriverBasicInfoResponse;
import com.yn.common.response.driver.DriverCountResponse;
import com.yn.common.response.driver.DriverIncomeResponse;

import com.yn.common.utils.genutils.CommonResult;
import com.yn.service.service.DriverHomeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;


/**
 * 司机端统计 -- 我的主页 前端控制器
 *
 */
@Slf4j
@RestController
@RequestMapping("api/driver/home")
@Api(tags = "司机端——我的页面")
public class DriverHomeController {

    @Autowired
    private DriverHomeService driverHomeService;


    /**
     * 返回司机基本信息
     * */
    @GetMapping("/statistics/info")
    @ApiOperation(value = "司机基本信息")
    public CommonResult<DriverBasicInfoResponse> getBasicInfo() {
        return CommonResult.success(driverHomeService.getBasicInfo());
    }


    /**
     * 统计司机接单总数和订单总额
     * */
    @GetMapping("/statistics/orders")
    @ApiOperation(value = "统计司机接单及金额")
    public CommonResult<DriverCountResponse> takeOrder() {
        DriverCountResponse response=driverHomeService.count();
        return CommonResult.success(response);
    }

    /**
     *设置上岗状态
     * */
   /* @PutMapping("/setCarStatus/{carStatus}")
    @ApiOperation(value = "设置上岗状态")
    public CommonResult<String> setCarStatus(@PathVariable @Validated Integer carStatus) {
        driverHomeService.setCarStatus(carStatus);
        return CommonResult.success();
    }*/

    /**
     * 设置岗位状态
     *
     * */
    @PutMapping("/setCarStatus/{postStatus}")
    @ApiOperation(value = "设置上岗状态")
    public CommonResult<String> setFleetStatus(@PathVariable @Validated Integer postStatus) {
        driverHomeService.setFleetCarStatus(postStatus);
        return CommonResult.success();
    }

    /**
     * 我的收入——展示订单列表和我的收益总额
     * */
    @GetMapping("/statistics/income")
    @ApiOperation(value = "我的收入")
    public CommonResult<DriverIncomeResponse> myIncome() {

        return CommonResult.success(driverHomeService.myIncome());
    }

    /**
     * 我的认证—
     * */
    @GetMapping("/statistics/identity")
    @ApiOperation(value = "我的认证")
    public CommonResult<BasicInfoResponse> myIdentity() {

        return CommonResult.success(driverHomeService.myIdentity());
    }

    /**
     * 删除车队绑定
     * carFleetId 车队id
     * @return
     */
    @DeleteMapping("/delete/binding/{carFleetId}")
    @ApiOperation(value = "解绑车队信息")
    public CommonResult<String>  deleteIdentity(@PathVariable @NotNull Integer carFleetId) {
        driverHomeService.deleteIdentity(carFleetId);
        return CommonResult.success("解绑成功");
    }


    /**
     *
     * 展示我的收入里的订单详情
    * */
   /* @PutMapping("/statistics/income/detail")
    @ApiOperation(value = "订单详情")
    public CommonResult<DriverIncomeResponse> myOrderDetail(@RequestParam(required = true,value = "orderNo") String orderNo) {
        driverHomeService.myOrderDetail(orderNo);
        return CommonResult.success();
    }*/
}

